(defun isInteger(x)
  (typep x 'integer))

(defun checkStringForInteger(x)
  (typep (ignore-errors (parse-integer x)) 'integer ))

(defun checkStringForListOfIntegers(x)
  (containsOnlyPositiveIntegers x))

(defun isPositveInteger(x)
  (and (isinteger x)
       (> x 0)))

(defun containsOnlyPositiveIntegers(input)
  "given a list, check all elements"
  (if (= (length (remove-if-not #'isPositveInteger input)) (length input)) T nil))

(defun split-by-one-space (string)
    "Returns a list of substrings of string
divided by ONE space each.
Note: Two consecutive spaces will be seen as
if there were an empty string between them.
http://cl-cookbook.sourceforge.net/strings.html"
    (loop for i = 0 then (1+ j)
          as j = (position #\Space string :start i)
          collect (parse-integer (subseq string i j))
          while j))

;http://hampshire.edu/~lasccs/courses/string-to-list.lisp
(defun string-to-list (string)
  "Returns a list of the data items represented in the given list."
  (let ((the-list nil) ;; we'll build the list of data items here
        (end-marker (gensym))) ;; a unique value to designate "done"
    (loop (multiple-value-bind (returned-value end-position)
                               (read-from-string string nil end-marker)
            (when (eq returned-value end-marker)
              (return the-list))
            ;; if not done, add the read thing to the list
            (setq the-list 
                  (append the-list (list returned-value)))
            ;; and chop the read characters off of the string
            (setq string (subseq string end-position))))))
